/**
 * @created June 7, 2004
 * @author Equipe SimPack 2004
 *
 * This classe is a format used by IHM to communicate
 * informations about a WishedEmission to the Simulator
 *
 * @modified March 8, 2007
 * @author adelaye
 * @author jprieur
 */
package kernel;
import java.util.Vector;
import utils.Debug;
import objects.Station;

public class DataWishedEmission extends DataType 
{  
    /**
     * Starting time of the wishedEmission
     */
    public double _startTime ;
    public final static double START_TIME_DEF = 0;
    public final static double START_TIME_MIN = 0;

    /**
     * Vector of stations destination
     */
    public Vector<String> _receivers ;

    /**
     * vector of parameters of this wishedEmission, 
     * So far it contains only the size of data
     */
    public Vector<String> _parameters;

    /**
     * default constructor
     */
    public DataWishedEmission(){
	setStartTime(START_TIME_DEF);
	setReceivers(new Vector());
	setParameters(new Vector());
    }	

    /**
     * Constructor
     * @param startTime
     * @param dests
     * @param params
     */
    public DataWishedEmission(double startTime,Vector<String> dests, Vector<String> l) {
	setStartTime(startTime);
	setReceivers(dests);
	setParameters(l);	
    }

    public boolean setReceivers(Vector<String> dests){
	_receivers = dests;
	for(int i=0;i<dests.size();i++){
	    String name = dests.get(i);
	    Station s = Simulator.getSimulator().getStationFromName(name);
	    if(s == null){
		Debug.getConfigLogger().warning("The station "+name+" is used as a destination but not yet declared");
	    }
	}
	return true;
    }

    public Vector<String> getReceivers(){
	return _receivers;
    }
    
    public boolean setParameters(Vector<String> params){
	_parameters = params;
	return true;
    }

    public Vector<String> getParameters(){
	return _parameters;
    }
    
    public boolean setStartTime(double startTime){
	boolean done = false;
	if(checkBounds(START_TIME_MIN,UNDEFINED,startTime)){
	    _startTime = startTime;
	    done = true;
	}else{
	    _startTime = START_TIME_DEF;
	}
	return done;
    }
    
    public double getStartTime(){
	return _startTime;
    }

    /**
     * This method gives the string associated to a wishedEmission
     */
    public String toString()
    {
	String s = "StartTime : "+_startTime/1000 + " Receivers : ";
	for (int i = 0;i<_receivers.size();i++)
	    s+= (String)_receivers.get(i)+ ";";
	s+=" Parameters : ";
	for (int i = 0;i<this._parameters.size();i++)
	    s+= (String)_parameters.get(i)+ ";";
	s+="\n";	
	return(s);
    }

}
